package com.yq.socket1.day1.practice.test2;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author 3307235355@qq.com
 * @description 客户端读取文本文件，服务器输出
 * @since 2022/07/01 14:15
 */
public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8888);

        Socket socket = serverSocket.accept();

        InputStream inputStream = socket.getInputStream();

        byte[] bytes = new byte[1024];
        int read;
        while ((read=inputStream.read(bytes))!=-1){
            System.out.println(new String(bytes,0,read));
        }
        System.out.println("打印完成！1");

        socket.close();
        serverSocket.close();
    }
}
